package com.syn.synold4s.adapter;


import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.core.content.ContextCompat;

import com.gaoyi.basemodule.baseAdapter.BaseWidgetAdapter;
import com.gaoyi.basemodule.basebean.ProjectDto;
import com.syn.synold4s.R;
import com.syn.synold4s.databinding.PopupTvBinding;

import java.util.List;

public class PopupProjectAdapter extends BaseWidgetAdapter<PopupTvBinding, ProjectDto> {

    private final Drawable mDrawable;

    public PopupProjectAdapter(Context context, List<ProjectDto> list) {
        super(context, list);
        mDrawable = ContextCompat.getDrawable(context, R.drawable.ic_done);
        if (mDrawable != null) {
            mDrawable.setBounds(0, 0, mDrawable.getIntrinsicWidth(), mDrawable.getIntrinsicHeight());
        }
    }

    @Override
    protected void initView(PopupTvBinding binding, ProjectDto item, int position) {
        binding.tvPopup.setText(item.getName());
        binding.tvPopup.setCompoundDrawablesRelative(null, null, item.isSelect() ? mDrawable : null, null);
        binding.tvPopup.setTextColor(ContextCompat.getColor(mContext, item.isSelect() ? R.color.color_main : R.color.black));
    }

    @Override
    protected PopupTvBinding getViewBinding(LayoutInflater inflater, ViewGroup viewGroup) {
        return PopupTvBinding.inflate(inflater, viewGroup, false);
    }
}
